﻿using AVCUMPlatform.DingTalkService.Model;
using AVCUMPlatform.HelperLibrary;
using AVCUMPlatform.SMSService.Interface;
using AVCUMPlatform.SMSService.Model;

namespace AVCUMPlatform.SMSService.Service
{
    public class SMSService : ISMSPlatformApiHelper
    {
        /// <summary>
        /// appid
        /// </summary>
        private string _appid { get; set; }
        /// <summary>
        /// appSecret
        /// </summary>
        private string _appSecret { get; set; }
        /// <summary>
        /// 客户端地址
        /// </summary>
        private string _clientHost { get; set; }
        /// <summary>
        /// hosturl
        /// </summary>
        public static string host = string.Empty;
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="appSecret"></param>
        public SMSService(string appid, string appSecret, string clientHost)
        {
            _appid = appid;
            _appSecret = appSecret;
            _clientHost = clientHost;
        }

        /// <summary>
        /// 发送短信消息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public SMSRes SendTemplateMsg(SMSSendContent data)
        {
            try
            {
                string url = $"{_clientHost}";
                return HTTPHelper.Post<SMSRes>(url, data);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
